<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <link rel="icon" href="/favicon.ico" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>Vite App</title>
</head>

<body>
  <div id="app"></div>
  <script type="module" src="/src/main.ts"></script>
  <script>
    function htmlFontSize() {
      var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
      var width = w > 750 ? 750 : w
      var fz = ~~((width * 100000) / 37.5) / 10000
      var html = document.querySelector('html')
      html.style.cssText = 'font-size: ' + fz + 'px'
      var realfz = ~~(+window.getComputedStyle(html).fontSize.replace('px', '') * 10000) / 10000
      if (fz !== realfz) {
        html.style.cssText = 'font-size: ' + fz * (fz / realfz) + 'px'
      }
    }

    function isMobile() {
      var isPhone = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) != null
      var isVPhone = window.name === 'mobile'
      return isPhone || isVPhone
    }
    var parts = location.pathname.replace(/(^\/|\/$)/g, '').split('/')
    if (isMobile()) {
      if (parts[0] !== 'm') {
        // location.href = ['', 'm'].concat(parts).join('/')
        location.href = '/m'
      }
      // document.querySelector('html').classList.add('mobile-model')
      // rem for mobile
      window.addEventListener(
        'resize',
        (function () {
          htmlFontSize()
          return arguments.callee
        })(),
        false
      )
    } else {
      if (parts[0] === 'm') {
        location.href = '/'
      }
    }
  </script>
</body>

</html>